<template>
    <div>
         <yd-navbar>
            <img slot="center" src="http://static.ydcss.com/www/img/logo.png"/>
        </yd-navbar>
         <yd-search :result="result" fullpage v-model="value2" :item-click="itemClickHandler" :on-submit="submitHandler"></yd-search>
    </div>
</template>

<script>
export default {
    name:"Mtop",
    data(){
        return{
           value2: '',
           result: []
        }
    },
    methods: {
            getResult(val) {
                if (!val) return [];
                return [
                    'Apple', 'Banana', 'Orange', 'Durian', 'Lemon', 'Peach', 'Cherry', 'Berry',
                    'Core', 'Fig', 'Haw', 'Melon', 'Plum', 'Pear', 'Peanut', 'Other'
                ].filter(value => new RegExp(val, 'i').test(value));
            },
            itemClickHandler(item) {
                this.$dialog.toast({mes: `搜索：${item}`});
            },
            submitHandler(value) {
                this.$dialog.toast({mes: `搜索：${value}`});
            }
        },
        watch: {
            value2(val) {
                this.result = this.getResult(val);
            }
        }
}
</script>

